home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Utilities / MungeImage 1.2.0 / MungeLibs.p < prev    next >
Encoding:
Text File  |  1994-08-15  |  1.5 KB  |  58 lines  |  [TEXT/PJMM]

  1. unit MungeLibs;
  2.  
  3. interface
  4.  
  5.     uses
  6.         EPPC, AppleEvents;
  7.  
  8.     function UDecStr (n: longint): Str15;
  9.     function FSReadQ (refnum: integer; count: longint; buf: Ptr): OSErr;
  10.     function MyFSWriteAt (refnum: integer; mode: integer; pos, len: longInt; p: ptr): OSErr;
  11.     function AEGetParamBoolean (event: AppleEvent; key: AEKeyword; var b: boolean): OSErr;
  12.  
  13. implementation
  14.  
  15.     function UDecStr (n: longint): Str15;
  16.     (* This horror is courtesy of Peter Lewis <peter.lewis@info.curtin.edu.au> *)
  17.         var
  18.             s: Str15;
  19.     begin
  20.         s := '';
  21.         repeat
  22.             s := concat(chr(48 + (n mod 10 + 10 + (6 * ord(n < 0))) mod 10), s);
  23.             n := BAND(BSR(n, 1), $7FFFFFFF) div 5;
  24.         until n = 0;
  25.         UDecStr := s;
  26.     end; (* UDecStr *)
  27.  
  28.     function FSReadQ (refnum: integer; count: longint; buf: Ptr): OSErr;
  29.     begin
  30.         FSReadQ := FSRead(refnum, count, buf);
  31.     end; (* FSReadQ *)
  32.  
  33.     function MyFSWriteAt (refnum: integer; mode: integer; pos, len: longInt; p: ptr): OSErr;
  34.         var
  35.             pb: ParamBlockRec;
  36.             oe: OSErr;
  37.     begin
  38.         pb.ioRefNum := refnum;
  39.         pb.ioBuffer := p;
  40.         pb.ioReqCount := len;
  41.         pb.ioPosMode := mode;
  42.         pb.ioPosOffset := pos;
  43.         oe := PBWriteSync(@pb);
  44.         if (oe = noErr) & (pb.ioActCount <> len) then begin
  45.             oe := -1;
  46.         end;
  47.         MyFSWriteAt := oe;
  48.     end;
  49.  
  50.     function AEGetParamBoolean (event: AppleEvent; key: AEKeyword; var b: boolean): OSErr;
  51.         var
  52.             realtype: DescType;
  53.             realsize: Size;
  54.     begin
  55.         AEGetParamBoolean := AEGetParamPtr(event, key, typeBoolean, realtype, @b, 1, realsize);
  56.     end; (* AEGetParamBoolean *)
  57.  
  58. end. (* MungeLibs *)